import { defineConfig } from 'vite';
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
import mkcert from 'vite-plugin-mkcert';
import dts from 'vite-plugin-dts';
import rollupCopy from 'rollup-plugin-copy';
// https://vitejs.dev/config/
export default defineConfig({
    build: {
        lib: {
            entry: resolve(__dirname, 'lib/weilasdk/weila.ts'),
            name: 'weilasdk_lite',
            fileName: 'weilasdk_lite',
        },
        target: ['es2015'],
        rollupOptions: {
            external: ['vue'],
            output: {
                globals: {
                    vue: 'Vue'
                }
            }
        }
    },
    server: {
        host: '0.0.0.0',
        port: 8080,
        // @ts-ignore
        https: true
    },
    plugins: [
        dts({ tsconfigPath: './tsconfig.app.json' }),
        vue(),
        mkcert(),
        rollupCopy({
            targets: [{
                    src: "lib/weilasdk/proto/weilapb.d.ts",
                    dest: "dist/lib/weilasdk/proto",
                }],
            verbose: true,
            hook: 'writeBundle'
        })
    ],
    resolve: {
        alias: {
            'sdk': resolve(__dirname, 'lib/weilasdk'),
            '@': resolve(__dirname, 'src')
        }
    }
});
